#region Using statements

using System;
using System.Collections.Generic;
using System.Text;
using Gremlin.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

#endregion

namespace Squadron
{
    class MachineGun : Gun
    {
        public MachineGun(Microsoft.Xna.Framework.Game game, ContentManager content, string modelName,
            String projectileMeshName, uint damage, int firingCooldown)
            : base(game, content, modelName)
        {
            contentManager = content;
            this.projectileMeshName = projectileMeshName;
            this.damage = damage;
            this.firingCooldown = firingCooldown;
        }

        public override Projectile Fire(Quaternion rotation)
        {
            if (coolDownTimer <= 0)
            {
                // Create a new bullet.
                Projectile bullet = new Projectile(_game, contentManager, projectileMeshName, rotation, 1000, damage, 0.9f);
                
                Vector3 dir = new Vector3(0, 0, -1);
                Matrix m = Matrix.CreateFromQuaternion(rotation);
                dir = Vector3.TransformNormal(new Vector3(0, 0, -1), m);

                bullet.Position = this.Position + dir * 2;
                coolDownTimer = firingCooldown;

                return bullet;
            }
            else
                return null;
        }   
    }
}
